USE Master;
DROP DataBase USS;
CREATE DataBase USS;

CREATE TABLE [Entity]
([Id]
    char(36)  PRIMARY KEY NOT NULL,
[Type]
    varchar(255)
);

CREATE TABLE [Attribute]
([Name]
    varchar(255),
[Type]
    varchar(255),
[Value]
    varchar(1024),
[FK_Entity]
    char(36) 
);

CREATE TABLE [Reference]
([Role]
    varchar(255),
[FK_Parent]
    char(36),
[FK_Child]
    char(36)
);

ALTER TABLE [Attribute]
ADD CONSTRAINT Id_FK_Entity FOREIGN KEY (FK_Entity) REFERENCES Entity(Id);

ALTER TABLE [Reference]
ADD CONSTRAINT Id_FK_Parent FOREIGN KEY (FK_Parent) REFERENCES Entity(Id);

ALTER TABLE [Reference]
ADD CONSTRAINT Id_FK_Child FOREIGN KEY (FK_Child) REFERENCES Entity(Id);
